home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Syn Text Editor 2.1.0.46 / synsetup-2.1.0.46.exe / {app} / scripts / exportpdf.vbs < prev    next >
Text File  |  2003-08-13  |  8KB  |  248 lines

  1. ' Caption: Export to PDF...|
  2. ' Hint: Export to PDF file using HTMLDOC|
  3. ' Icon: expdf.ico|
  4. '
  5. '  syn
  6. '  Copyright (C) 2000-2003, Ascher Stefan. All rights reserved.
  7. '  stievie@utanet.at, http://web.utanet.at/ascherst/
  8. '
  9. '  The contents of this file are subject to the Mozilla Public License
  10. '  Version 1.1 (the "License"); you may not use this file except in compliance
  11. '  with the License. You may obtain a copy of the License at
  12. '  http://www.mozilla.org/MPL/
  13. '
  14. '  Software distributed under the License is distributed on an "AS IS" basis,
  15. '  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  16. '  the specific language governing rights and limitations under the License.
  17. '
  18. '  The Original Code is exportpdf.vbs, released Sun, 26 May 2002 10:55:39 UTC.
  19. '
  20. '  The Initial Developer of the Original Code is Ascher Stefan.
  21. '  Portions created by Ascher Stefan are Copyright (C) 2000-2003 Ascher Stefan.
  22. '  All Rights Reserved.
  23. '
  24. '  Contributor(s): .
  25. '
  26. '  Alternatively, the contents of this file may be used under the terms of the
  27. '  GNU General Public License Version 2 or later (the "GPL"), in which case
  28. '  the provisions of the GPL are applicable instead of those above.
  29. '  If you wish to allow use of your version of this file only under the terms
  30. '  of the GPL and not to allow others to use your version of this file
  31. '  under the MPL, indicate your decision by deleting the provisions above and
  32. '  replace them with the notice and other provisions required by the GPL.
  33. '  If you do not delete the provisions above, a recipient may use your version
  34. '  of this file under either the MPL or the GPL.
  35. '
  36. '  You may retrieve the latest version of this file at the syn home page,
  37. '  located at http://syn.sourceforge.net/
  38. '
  39. ' $Id: exportpdf.vbs,v 1.3.2.5 2003/08/13 00:38:45 neum Exp $
  40.  
  41. ' This Script Exports the active file with Syntaxhighlight to a PDF file using
  42. ' HTMLDOC, you can get it for free from http://www.easysw.com/htmldoc/. You can
  43. ' customize the appearance with modifing the commandline options, see the HTMLDOC
  44. ' Manual.
  45. ' You need the commandline version from HTMLDOC, but there is no precompiled
  46. ' distribution available. You may want to download the source code, and compile
  47. ' it yourself, or you can use an older version.
  48.  
  49. 'HTMLDOC Version 1.8.19 Copyright 1997-2002 Easy Software Products, All Rights Reserved.
  50. 'This software is governed by the GNU General Public License, Version 2, and
  51. 'is based in part on the work of the Independent JPEG Group.
  52. '
  53. 'Usage:
  54. '  htmldoc [options] filename1.html [ ... filenameN.html ]
  55. '
  56. 'Options:
  57. '
  58. '  --batch filename.book
  59. '  --bodycolor color
  60. '  --bodyfont {courier,times,helvetica}
  61. '  --bodyimage filename.{gif,jpg,png}
  62. '  --book
  63. '  --bottom margin{in,cm,mm}
  64. '  --browserwidth pixels
  65. '  --charset {8859-1...8859-15}
  66. '  --color
  67. '  --compression[=level]
  68. '  --datadir directory
  69. '  --duplex
  70. '  --effectduration {0.1..10.0}
  71. '  --encryption
  72. '  --firstpage {p1,toc,c1}
  73. '  --fontsize {6.0..24.0}
  74. '  --fontspacing {1.0..3.0}
  75. '  --footer fff
  76. '  {--format, -t} {ps1,ps2,ps3,pdf11,pdf12,pdf13,pdf14,html}
  77. '  --gray
  78. '  --header fff
  79. '  --headfootfont {courier{-bold,-oblique,-boldoblique},
  80. '                  times{-roman,-bold,-italic,-bolditalic},
  81. '                  helvetica{-bold,-oblique,-boldoblique}}
  82. '  --headfootsize {6.0..24.0}
  83. '  --headingfont {courier,times,helvetica}
  84. '  --help
  85. '  --jpeg[=quality]
  86. '  --landscape
  87. '  --left margin{in,cm,mm}
  88. '  --linkcolor color
  89. '  --links
  90. '  --linkstyle {plain,underline}
  91. '  --logoimage filename.{gif,jpg,png}
  92. '  --owner-password password
  93. '  --no-compression
  94. '  --no-duplex
  95. '  --no-encryption
  96. '  --no-links
  97. '  --no-localfiles
  98. '  --no-numbered
  99. '  --no-pscommands
  100. '  --no-title
  101. '  --no-toc
  102. '  --no-truetype
  103. '  --numbered
  104. '  {--outdir, -d} dirname
  105. '  {--outfile, -f} filename.{ps,pdf,html}
  106. '  --pageduration {1.0..60.0}
  107. '  --pageeffect {none,bi,bo,d,gd,gdr,gr,hb,hsi,hso,vb,vsi,vso,wd,wl,wr,wu}
  108. '  --pagelayout {single,one,twoleft,tworight}
  109. '  --pagemode {document,outline,fullscreen}
  110. '  --path "dir1;dir2;dir3;...;dirN"
  111. '  --permissions {all,annotate,copy,modify,print,no-annotate,no-copy,no-modify,no-print,none}
  112. '  --portrait
  113. '  --proxy http://host:port
  114. '  --pscommands
  115. '  --quiet
  116. '  --right margin{in,cm,mm}
  117. '  --size {letter,a4,WxH{in,cm,mm},etc}
  118. '  --textcolor color
  119. '  --textfont {courier,times,helvetica}
  120. '  --title
  121. '  --titlefile filename.{htm,html,shtml}
  122. '  --titleimage filename.{gif,jpg,png}
  123. '  --tocfooter fff
  124. '  --tocheader fff
  125. '  --toclevels levels
  126. '  --toctitle string
  127. '  --top margin{in,cm,mm}
  128. '  --truetype
  129. '  --user-password password
  130. '  {--verbose, -v}
  131. '  --version
  132. '  --webpage
  133. '
  134. '  fff = heading format string; each 'f' can be one of:
  135. '
  136. '        . = blank
  137. '        / = n/N arabic page numbers (1/3, 2/3, 3/3)
  138. '        : = c/C arabic chapter page numbers (1/2, 2/2, 1/4, 2/4, ...)
  139. '        1 = arabic numbers (1, 2, 3, ...)
  140. '        a = lowercase letters
  141. '        A = uppercase letters
  142. '        c = current chapter heading
  143. '        C = current chapter page number (arabic)
  144. '        d = current date
  145. '        D = current date and time
  146. '        h = current heading
  147. '        i = lowercase roman numerals
  148. '        I = uppercase roman numerals
  149. '        l = logo image
  150. '        t = title text
  151. '        T = current time
  152.  
  153. option explicit
  154.  
  155. '#include <cmnfunc>
  156. '#include <consts>
  157.  
  158. ' You should modify the Path to HTMLDOC
  159. 'const htmldoc = "D:\Eigene Dateien\C Projects\htmldoc\visualc\htmldoc.exe"
  160. const htmldoc = "D:\Programme\htmldoc\htmldoc.exe"
  161.  
  162. sub Main(dummy)
  163.   if Documents.Count = 0 then
  164.     MsgBox "No Document open.", vbCritical
  165.     exit sub
  166.   end if
  167.   dim pdffile, htmfile
  168.   with Create("TSaveDialog", Self)
  169.     .Filter = "PDF Files (*.pdf)|*.pdf|All Files (*.*)|*.*"
  170.     .DefaultExt = "pdf"
  171.     .Options = .Options & ",ofOverwritePrompt"
  172.     .InitialDir = ExtractFilePath(ActiveDocument.FileName)
  173.     .FileName = ChangeFileExt(ActiveDocument.FileName, ".pdf")
  174.     .Title = "Export to PDF"
  175.     if .Execute then
  176.       Cursor = crHourGlass
  177.       pdffile = .FileName
  178.       htmfile = TempFile
  179.       if ActiveDocument.TypeName = "Text" then
  180.         ' Export does not work with plain text files
  181.         StringToFile "<pre>" & ActiveDocument.Text & "</pre>", htmfile
  182.       else
  183.         ActiveDocument.Export etHTML, false, htmfile
  184.       end if
  185.       if FileExists(htmfile) then
  186.         Execute AddQuotesUnless(htmldoc) & " -t pdf13 --webpage --size a4 --pagelayout single " & _
  187.         AddQuotesUnless(htmfile) & " -f " & AddQuotesUnless(pdffile), 0, true
  188.         DeleteFile(htmfile)
  189.       else
  190.         MsgBox "Something went wrong while exporting the file.", vbCritical
  191.       end if
  192.       Cursor = crDefault
  193.     end if
  194.     .Free
  195.   end with
  196. end sub
  197.  
  198.  
  199. ' If you want to export all currently open files uncomment the lines bellow, and
  200. ' delete the Sub Main above
  201.  
  202. 'sub Main()
  203. '  if Documents.Count = 0 then
  204. '    MsgBox "No Document open.", vbCritical
  205. '    exit sub
  206. '  end if
  207. '  dim dlg
  208. '  dim pdffile, htmfile
  209. '
  210. '  dlg = Create("TSaveDialog", Self)
  211. '  with dlg
  212. '    .Filter = "PDF Files (*.pdf)|*.pdf|All Files (*.*)|*.*"
  213. '    .DefaultExt = "pdf"
  214. '    .Options = .Options & ",ofOverwritePrompt"
  215. '    .Title = "Export to PDF"
  216. '  end with
  217. '  dim i
  218. '  dim doc
  219. '  for i = 0 to Documents.Count - 1
  220. '    set doc = Documents(i)
  221. '    with dlg
  222. '      .InitialDir = RemoveFileName(doc.FileName)
  223. '      .FileName = ChangeFileExt(doc.FileName, ".pdf")
  224. '      if .Execute then
  225. '        Cursor = crHourGlass
  226. '        pdffile = .FileName
  227. '        htmfile = ChangeFileExt(pdffile, ".html")
  228. '        if doc.TypeName = "Text" then
  229. '          ' Export does not work with plain text files
  230. '          StringToFile "<pre>" & doc.Text & "</pre>", htmfile
  231. '        else
  232. '          doc.Export etHTML, false, htmfile
  233. '        end if
  234. '        if FileExists(htmfile) then
  235. '          Execute AddQuotesUnless(htmldoc) & " -t pdf13 --webpage --size a4 --pagelayout single " & _
  236. '          AddQuotesUnless(htmfile) & " -f " & AddQuotesUnless(pdffile), 0, true
  237. '        else
  238. '          MsgBox "Something went wrong while exporting the file.", vbCritical
  239. '        end if
  240. '        DeleteFile(htmfile)
  241. '        Cursor = crDefault
  242. '      end if
  243. '    end with
  244. '  next
  245. '  dlg.Free
  246. 'end sub
  247.  
  248.